//
//  YQBigVidaDetailCtl.m
//  OverseasImmigration
//
//  Created by yuqin on 2019/6/8.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQBigVidaDetailCtl.h"
#import "YQDetailCell.h"

@interface YQBigVidaDetailCtl ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>

@property (nonatomic, strong) UITableView *detailTB;
@property (nonatomic, strong) NSMutableArray *dataArr;

@end

@implementation YQBigVidaDetailCtl

- (NSMutableArray *)dataArr {
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"签证说明";
    //创建UI
    [self setupBigVisaView];
    //相亲数据
    [self loadVisaDetailData];
}

- (void)loadVisaDetailData {
    [[HTTPRequstManger sharedHTTPRequstManger] getRequestWithUrlString:YQ_String_Url(@"user/visa/detail") appendParameters:@{@"id":self.idStr} successBlock:^(id responseObject) {
        NSArray *data = responseObject[@"data"];
        for (NSDictionary *dict in data) {
            YQBigVisaDetailModel *model = [YQBigVisaDetailModel mj_objectWithKeyValues:dict];
            [self.dataArr addObject:model];
        }
        [self.detailTB reloadData];
    } failureBlock:^(NSError *error) {
        
    }];
}

- (void)setupBigVisaView {
    self.detailTB = [[UITableView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, SCREENWIDTH, kTableViewHeight) style:UITableViewStylePlain];
    self.detailTB.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.detailTB.delegate = self;
    self.detailTB.dataSource = self;
    self.detailTB.tableFooterView = [[UIView alloc] init];
    YQ_EmptyView(self.detailTB);
    [self.detailTB registerNib:[UINib nibWithNibName:YQ_VISA_DETAIL_CELL bundle:nil] forCellReuseIdentifier:YQ_VISA_DETAIL_CELL];
    [self.view addSubview:self.detailTB];
}

YQ_Empty_Deletage_DataSources(@"暂无数据");
#pragma mark - 代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(250);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_VISA_DETAIL_CELL forIndexPath:indexPath];
    YQBigVisaDetailModel *model = self.dataArr[indexPath.row];
    cell.detailModel = model;
    NSDictionary *dict = @{@"1":@"诚实签证(定向服务)",
                           @"2":@"美国商务签证（自备邀请)",
                           @"3":@"美国探亲访友签证"
                           };
    cell.visaWayLab.text = [dict objectForKey:StringFromLongInt(indexPath.row+1)];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
